package com.eneat.smartrule.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 操作符枚举
 */
@Getter
@AllArgsConstructor
public enum ComparisonOperatorEnum {
    EQ("==", "等于"),
    NE("!=", "不等于"),
    GTE(">=", "大于等于"),
    LTE("<=", "小于等于"),
    GT(">", "大于"),
    LT("<", "小于");


    private final String code;
    private final String desc;

    public static ComparisonOperatorEnum fromCode(String code) {
        for (ComparisonOperatorEnum op : values()) {
            if (op.getCode().equals(code)) {
                return op;
            }
        }
        throw new IllegalArgumentException("未知的操作符: " + code);
    }
}
